#include <iostream>

class complex
{
private:
    double re;
    double im;

public:
    complex(double r, double i) : re{r}, im{i} {}
    complex(double r) : re{r}, im{0} {}
    complex() : re{0}, im{0} {}

    double real() const { return re; }
    void real(double d) { re = d; }
    double image() const { return im; }
    void image(double d) { im = d; }
    complex &operator+=(complex z)
    {
        re += z.re, im += z.im;
        return *this;
    }
    complex &operator-=(complex z)
    {
        re -= z.re, im -= z.im;
        return *this;
    }
    complex &operator*=(complex);
    complex &operator/=(complex);
};

complex &complex::operator*=(complex z)
{
    re = re * z.re - im * z.im;
    im = im * z.re + re * z.im;
    return *this;
}

complex &complex::operator/=(complex z)
{
    double denominator = z.re * z.re + z.im + z.im;
    re = (re * z.re + im * z.im) / denominator;
    im = (im * z.re - re * z.im) / denominator;
    return *this;
}

complex operator+(complex a, complex b) { return a += b; }
complex operator-(complex a, complex b) { return a -= b; }
complex operator-(complex a) { return {-a.real(), -a.image()}; }
complex operator*(complex a, complex b) { return a *= b; }
complex operator/(complex a, complex b) { return a /= b; }
bool operator==(complex a, complex b)
{
    return a.real() == b.real() && a.image() == b.image();
}
bool operator!=(complex a, complex b)
{
    return !(a == b);
}

void test_complex(complex z)
{
    complex a{2.3};
    complex b{1 / a};
    complex c{a + z * complex{1, 2.3}};
    if (c != b)
        c = -(b / a) + 2 * b;
}

int main(int argc, char const *argv[])
{
    test_complex(complex{1, 2});
    return 0;
}
